/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */
import type { MaFormItem } from '@mineadmin/form'
import hasAuth from '@/utils/permission/hasAuth.ts'
import MaDictSelect from '@/components/ma-dict-picker/ma-dict-select.vue'
import MaDictRadio from '@/components/ma-dict-picker/ma-dict-radio.vue'
import MaWangEditor from '$/attractions/attraction-management/components/MaWangEditor.vue'
import MaUploadImage from '@/components/ma-upload-image/index.vue'
import { concat } from 'lodash-es'

export default function getFormItems(formType: 'add' | 'edit' = 'add', t: any, model: any): MaFormItem[] {
    // 设置新增时的默认值
    if (formType === 'add') {
      model.status = 1  // 默认状态为正常
    }

    return concat([
    { label: '景区名称', prop: 'name', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '景区名称'}) }, itemProps: { rules: [
    { required: true, message: '请输入景区名称' },
  ] } },
    { label: '介绍标题', prop: 'intro_title', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '介绍标题'}) } },
    { 
      label: '景区介绍', 
      prop: 'intro', 
      render: () => MaWangEditor, 
      renderProps: { 
        height: 400,
        placeholder: '请输入景区介绍...'
      }
    },
    { 
      label: '封面图片', 
      prop: 'cover_id', 
      render: () => MaUploadImage, 
      renderProps: { 
        multiple: false,
        limit: 1,
        title: '上传封面',
        size: 150
      }
    },
    { label: '地址', prop: 'address', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '地址'}) } },
    { label: '联系电话', prop: 'phone', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '联系电话'}) } },
    { label: '开门时间', prop: 'open_time', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '开门时间'}) } },
    { label: '关门时间', prop: 'close_time', render: 'input', renderProps: { placeholder: t('form.pleaseInput', { msg: '关门时间'}) } },
    { 
      label: '状态', 
      prop: 'status', 
      render: () => MaDictSelect, 
      renderProps: { 
        placeholder: '请选择状态', 
        multiple: false,
        options: [
          { label: '正常', value: 1 },
          { label: '禁止', value: 2 }
        ]
      }, 
      itemProps: { 
        rules: [
          { required: true, message: '请选择状态' }
        ] 
      } 
    },
  ]);
}
